/**
 * 
 */
package com.hcmu.view.custome;

import java.util.ArrayList;
import java.util.List;

import org.w3c.dom.Text;

import com.hcmu.dto.StoryDTO;
import com.telpoo.truyencuoi.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

/**
 * @author SEVEN
 *
 */
public class StoriesListAdapter extends ArrayAdapter<StoryDTO> {
	private Context _context;
	private ArrayList<StoryDTO> _storiesList;
	protected View itemView;
	private ImageView im_Icon;
	private TextView txtTitle;
	LayoutInflater lf;
	
	
	public StoriesListAdapter(Context context, int textViewResourceId,
			List<StoryDTO> objects) {
		super(context, textViewResourceId, objects);
		
		this._context = context;
		this._storiesList = (ArrayList<StoryDTO>) objects;
		
		lf = LayoutInflater.from(_context);
	}

	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		itemView = lf.inflate(R.layout.story_item, null);
		im_Icon = (ImageView) itemView.findViewById(R.id.icon);
		txtTitle = (TextView) itemView.findViewById(R.id.txtTitle);
		
		
		im_Icon.setBackgroundResource(_storiesList.get(position).getIcon());
		txtTitle.setText(_storiesList.get(position).getTitle());
		txtTitle.setTag(_storiesList.get(position).getId());
		
		return itemView;
	}

}
